//
//  User.m
//  Sofia
//
//  Created by Anton Chebotaev on 19/11/08.
//  Copyright 2008 IFMO. All rights reserved.
//

#import "SFUserAccount.h"


@implementation SFUserAccount

@synthesize username;
@synthesize password;

- (id)init
{
    [self dealloc];
    @throw [NSException exceptionWithName:@"BNRBadInitCall"
								   reason:@"Initialize SFUserAccount without parameters"
								 userInfo:nil];
    return nil;
}

- (id)initWithName:(NSString *)un 
		  password:(NSString *)pw 
{
    if (![super init])
        return nil;
    username = [[NSString alloc] initWithString:un];
	password = [[NSString alloc] initWithString:pw];
    return self;	
}

- (void)dealloc
{
    [username release];
    [password release];
    [super dealloc];
}

- (NSString *)description
{
	return [NSString stringWithFormat:@"username '%@' with password '%@'", username, password];
}

- (void)encodeWithCoder:(NSCoder *)coder
{
	//NSLog(@"Enconding - %@", self);
    [coder encodeObject:username forKey:@"username"];
    [coder encodeObject:password forKey:@"password"];
}

- (id)initWithCoder:(NSCoder *)coder
{
	[super init];
	username = [[coder decodeObjectForKey:@"username"] retain];
	password = [[coder decodeObjectForKey:@"password"] retain];
	//NSLog(@"Deconding - %@", self);
	return self;
}

@end
